package com.zs.netlibrary.http.request.factory.impl;

import com.zs.netlibrary.http.request.factory.AbsRequestFactory;
import com.zs.netlibrary.http.request.IRequest;

/**
 *
 * Created by sheng on 2017/8/17.
 */

public class DefaultRequestFactory extends AbsRequestFactory {
    private static DefaultRequestFactory instance;

    private DefaultRequestFactory() {

    }

    public static DefaultRequestFactory getInstance() {
        if (instance == null) {
            instance = new DefaultRequestFactory();
        }
        return instance;
    }

    @Override
    public <T extends IRequest> T createRequest(Class<T> clazz) {
        try {
            // 反射
            return clazz.newInstance();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
}